//引入axios
import axios from '@/ulits/request'
import axios1 from 'axios'
export default {
  state: {
    categeroyList: null,
    bannerList: null,
    getFloorList: null,

  },
  getters: {

  },
  mutations: {
    CATEGEORYLIST(state, categeroyList) {
      state.categeroyList = categeroyList.slice(0, 16)
    },
    GETBANNERLIST(state, getBannnerList) {
      state.bannerList = getBannnerList
    },
    GETFLOORLIST(state, getFloorList) {
      state.getFloorList = getFloorList
    }
  },
  actions: {
    //获取服务器的数据
    async categeroyList(state) {
      const res = await axios.get('product/getBaseCategoryList')
      if (res.code === 200) {
        state.commit('CATEGEORYLIST', res.data)
      }
    },
    // 获取首页轮播图
    async getBannnerList(state) {
      const { data: res } = await axios1.get('/json/banner.json')
      state.commit('GETBANNERLIST', res)
    },
    //获取floor轮播图
    async getFloorList(state) {
      const { data: res } = await axios1.get('/json/floor.json')
      state.commit('GETFLOORLIST', res)
    }
  }
}